package com.ruoyi.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 全局配置类
 * 
 * @author ruoyi
 */
@Component
public class Global {

	/**
	 * 获取项目名称
	 */
	private static String name;
	
	@Value("${ruoyi.name:RuoYi}") 
	public static void setName(String name) {
		Global.name = name;
	}
	
	public static String getName() {
		return name;
	}

	/**
	 * 获取项目版本
	 */
	private static String version;
	
	@Value("${ruoyi.version:3.2.0}") 
	public static void setVersion(String version) {
		Global.version = version;
	}
	
	public static String getVersion() {
		return version;
	}

	/**
	 * 获取版权年份
	 */
	private static String copyrightYear;
	
	@Value("${ruoyi.copyrightYear:2019}")
	public static void setCopyrightYear(String copyrightYear) {
		Global.copyrightYear = copyrightYear;
	}
	
	public static String getCopyrightYear() {
		return copyrightYear;
	}

	/**
	 * 获取ip地址开关
	 */
	private static Boolean addressEnabled;
	
	@Value("${ruoyi.addressEnabled:false}")
	public static void setAddressEnabled(Boolean addressEnabled) {
		Global.addressEnabled = addressEnabled;
	}

	public static Boolean isAddressEnabled() {
		return addressEnabled;
	}

	/**
	 * 获取文件上传路径
	 */	
	private static String profile;
	
	@Value("${ruoyi.profile}")
	public static void setProfile(String profile) {
		Global.profile = profile;
	}
	
	public static String getProfile() {
		return profile;
	}

	/**
	 * 获取头像上传路径
	 */
	public static String getAvatarPath() {
		return getProfile() + "avatar/";
	}

	/**
	 * 获取下载路径
	 */
	public static String getDownloadPath() {
		return getProfile() + "download/";
	}

	/**
	 * 获取上传路径
	 */
	public static String getUploadPath() {
		return getProfile() + "upload/";
	}

	/**
	 * 获取作者
	 */
	private static String author;
	
	@Value("${gen.author:ruoyi}")
	public static void setAuthor(String author) {
		Global.author = author;
	}
	
	public static String getAuthor() {
		return author;
	}

	/**
	 * 生成包路径
	 */
	private static String packageName;
	
	@Value("${gen.packageName:com.ruoyi.project.module}")
	public static void setPackageName(String packageName) {
		Global.packageName = packageName;
	}
	
	public static String getPackageName() {
		return packageName;
	}

	/**
	 * 是否自动去除表前缀
	 */
	private static String autoRemovePre;
	
	@Value("${gen.autoRemovePre:true}")	
	public static void setAutoRemovePre(String autoRemovePre) {
		Global.autoRemovePre = autoRemovePre;
	}
	
	public static String getAutoRemovePre() {
		return autoRemovePre;
	}

	/**
	 * 表前缀(类名不会包含表前缀)
	 */
	private static String tablePrefix;
	
	@Value("${gen.tablePrefix:sys_}")
	public static void setTablePrefix(String tablePrefix) {
		Global.tablePrefix = tablePrefix;
	}	
	
	public static String getTablePrefix() {
		return tablePrefix;
	}
	
}
